package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 山顶洞人郑某
 * @className SetmealDishMapper.java
 * @date 2024 01 21
 */
@Mapper
public interface SetmealDishMapper {

    /**
     * 获取套餐信息
     * @param dishIds
     * @return
     */
    List<Long> getSetmealIdsByDishIds(@Param("dishIds") List<Long> dishIds);

    /**
     * 添加菜品和套餐关联外键表
     * @param setmealDishes
     */

    void insert(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id查询套餐和菜品的关联信息
     * @param setmealId
     * @return
     */

    @Select("select * from sky_take_out.setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getBySetmealId(Long setmealId);

    /**
     * 根据套餐id删除套餐菜品关联表信息
     * @param id
     */
    @Delete("delete  from sky_take_out.setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(@Param("id") Long id);

    /**
     * 根据套餐id批量删除套餐菜品关联表信息
     * @param ids
     */
    void deleteBySetmealIds(List<Long> ids);
}
